<extend name="Public/base"/>

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>[用户留存率] 列表</h2>
    </div>
	<div class="cf top_nav_list">
		<div class="fl button_list">
		</div>
		<!-- 高级搜索 -->
		<div class="search-form fr cf">
            <div class="input-list">
                <label>选择日期：</label>
                <input type="text" id="time-start" name="start" class="text input-2x" value="{:I('start')}" placeholder="起始时间" />
                -
                <input type="text" id="time-end" name="end" class="text input-2x" value="{:I('end')}" placeholder="结束时间" />
            </div>
            <div class="i_list" id="" >
                 <div class="drop-down" id="game">
                    <if condition="I('game_name') eq ''">
                    <input type="text" id="i_list_id" class="sort-txt" value="" placeholder="请选择游戏" name="game_name"/>
                    <else />
                    <input type="text" id="i_list_id" class="sort-txt" value="{:I('game_name')}" placeholder="请选择游戏" name="game_name"/>
                    </if>
                    <input type="hidden" id="i_list_idh" name="game_id" value="{:I('game_id')}" />
                    <i class="arrow arrow-down"></i>
                    <ul id="i_list_li" class="nav-list hidden i_list_li">
                        <li><a href="javascript:;" value="" >全部</a></li>
                        <volist name=":get_game_list()" id="vo">                        
                        <li><a href="javascript:;" value="{$vo.id}" >{$vo.game_name}</a></li>
                        </volist>
                    </ul>
                </div>                
            </div>
            <div class="i_list">
                 <div class="drop-down" id="promote">
                    <if condition="I('promote_name') eq ''">
                    <input type="text" id="i_list_id" class="sort-txt" name="promote_name" value="" placeholder="请选择所属渠道" />
                    <else />
                    <input type="text" id="i_list_id" class="sort-txt" name="promote_name" value="{:I('promote_name')}" placeholder="请选择所属渠道" />
                    </if>
                    <input type="hidden" id="i_list_idh" name="promote_id" value="{:I('promote_id')}" />
                    <i class="arrow arrow-down"></i>
                    <ul id="i_list_li" class="nav-list hidden i_list_li">
                        <li><a href="javascript:;" value="" >全部</a></li>
                        <li><a href="javascript:;" value="0" >自然注册</a></li>
                        <volist name=":get_promote_all()" id="vo">                        
                        <li><a href="javascript:;" value="{$vo.id}" >{$vo.account}</a></li>
                        </volist>
                    </ul>
                </div>                
            </div>
            <!-- <div class="sleft">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('stat/userretention','model='.$model['name'],false)}"><i class="btn-search"></i></a>
			</div> -->
          <!--   <div class="btn-group-click adv-sch-pannel fl">
                <button class="btn">高 级<i class="btn-arrowdown"></i></button>
                <div class="dropdown cf">
                    <div class="row">
                        
                    </div>
                </div>
            </div> -->
            <div class="input-list">
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('stat/userretention','model='.$model['name'],false)}">搜索</a>
            </div>
		</div>
	</div>

    <!-- 数据列表 -->
    <div class="data-table">
        <div class="data-table table-striped">
            <table>
                <!-- 表头 -->
                <thead>

                    <tr>
                        <th style="text-align:center">注册日期</th>           
                        <th style="text-align:center">新增用户数</th>
                        <th style="text-align:center">1日留存</th>
                        <th style="text-align:center">2日留存</th>
                        <th style="text-align:center">3日留存</th>
                        <th style="text-align:center">4日留存</th>
                        <th style="text-align:center">5日留存</th>
                        <th style="text-align:center">6日留存</th>
                        <th style="text-align:center">7日留存</th>
                        <th style="text-align:center">15日留存</th>
                        <th style="text-align:center">30日留存</th>
                        <th style="text-align:center">60日留存</th>
                    </tr>
                </thead>
                <!-- 列表 -->
                <tbody>
                 <!--<if condition="$t neq ''">
                          <tr>
                        <td style="text-align:center">{$t}</td>
                        <td style="text-align:center">{$one['yicount']}</td>
                        <td style="text-align:center">{$one['yiri']}</td>
                        <td style="text-align:center">{$one['erri']}</td>
                        <td style="text-align:center">{$one['sanri']}</td>
                        <td style="text-align:center">{$one['siri']}</td>
                        <td style="text-align:center">{$one['wuri']}</td>
                        <td style="text-align:center">{$one['liuri']}</td>
                        </tr>
                         <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +1 day"))</php></td>
                        <td style="text-align:center">{$tow['dyicount']}</td>
                        <td style="text-align:center">{$tow['dyiri']}</td>
                        <td style="text-align:center">{$tow['derri']}</td>
                        <td style="text-align:center">{$tow['dsanri']}</td>
                        <td style="text-align:center">{$tow['dsiri']}</td>
                        <td style="text-align:center">{$tow['dwuri']}</td>
                        <td style="text-align:center">{$tow['dliuri']}</td>
                        </tr>
                       <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +2 day"))</php></td>
                        <td style="text-align:center">{$three['syicount']}</td>
                        <td style="text-align:center">{$three['syiri']}</td>
                        <td style="text-align:center">{$three['serri']}</td>
                        <td style="text-align:center">{$three['ssanri']}</td>
                        <td style="text-align:center">{$three['ssiri']}</td>
                        <td style="text-align:center">{$three['swuri']}</td>
                        <td style="text-align:center">{$three['sliuri']}</td>
                        
                        </tr>
                         <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +3 day"))</php></td>
                        <td style="text-align:center">{$four['fyicount']}</td>
                        <td style="text-align:center">{$four['fyiri']}</td>
                        <td style="text-align:center">{$four['ferri']}</td>
                        <td style="text-align:center">{$four['fsanri']}</td>
                        <td style="text-align:center">{$four['fsiri']}</td>
                        <td style="text-align:center">{$four['fwuri']}</td>
                        <td style="text-align:center">{$four['fliuri']}</td>
                        </tr>
                        <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +4 day"))</php></td>
                        <td style="text-align:center">{$five['wyicount']}</td>
                        <td style="text-align:center">{$five['wyiri']}</td>
                        <td style="text-align:center">{$five['werri']}</td>
                        <td style="text-align:center">{$five['wsanri']}</td>
                        <td style="text-align:center">{$five['wsiri']}</td>
                        <td style="text-align:center">{$five['wwuri']}</td>
                        <td style="text-align:center">{$five['wliuri']}</td>
                        
                        </tr>
                        <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +5 day"))</php></td>
                        <td style="text-align:center">{$six['lyicount']}</td>
                        <td style="text-align:center">{$six['lyiri']}</td>
                        <td style="text-align:center">{$six['lerri']}</td>
                        <td style="text-align:center">{$six['lsanri']}</td>
                        <td style="text-align:center">{$six['lsiri']}</td>
                        <td style="text-align:center">{$six['lwuri']}</td>
                        <td style="text-align:center">{$six['lliuri']}</td>
                        
                        </tr>

                         <tr>
                         <td style="text-align:center"><php> echo date('Y-m-d',strtotime("$t +6 day"))</php></td>
                        <td style="text-align:center">{$seven['qyicount']}</td>
                        <td style="text-align:center">{$seven['qyiri']}</td>
                        <td style="text-align:center">{$seven['qerri']}</td>
                        <td style="text-align:center">{$seven['qsanri']}</td>
                        <td style="text-align:center">{$seven['qsiri']}</td>
                        <td style="text-align:center">{$seven['qwuri']}</td>
                        <td style="text-align:center">{$seven['qliuri']}</td>
                        </tr>
                    <else/>
                        <tr>
                        <td style="text-align:center">{:get_lastweek_name("6")}</td>
                        <td style="text-align:center">{$one['yicount']}</td>
                        <td style="text-align:center">{$one['yiri']}</td>
                        <td style="text-align:center">{$one['erri']}</td>
                        <td style="text-align:center">{$one['sanri']}</td>
                        <td style="text-align:center">{$one['siri']}</td>
                        <td style="text-align:center">{$one['wuri']}</td>
                        <td style="text-align:center">{$one['liuri']}</td>
                        </tr>
                          <tr>
                          <td style="text-align:center">{:get_lastweek_name("5")}</td>
                        <td style="text-align:center">{$tow['dyicount']}</td>
                        <td style="text-align:center">{$tow['dyiri']}</td>
                        <td style="text-align:center">{$tow['derri']}</td>
                        <td style="text-align:center">{$tow['dsanri']}</td>
                        <td style="text-align:center">{$tow['dsiri']}</td>
                        <td style="text-align:center">{$tow['dwuri']}</td>
                        <td style="text-align:center"></td>
                        </tr>
                           <tr>
                          <td style="text-align:center">{:get_lastweek_name("4")}</td>
                        <td style="text-align:center">{$three['syicount']}</td>
                        <td style="text-align:center">{$three['syiri']}</td>
                        <td style="text-align:center">{$three['serri']}</td>
                        <td style="text-align:center">{$three['ssanri']}</td>
                        <td style="text-align:center">{$three['ssiri']}</td>
                        <td style="text-align:center"></td>
                           <td style="text-align:center"></td>                        
                        </tr>
                        
                         <tr>
                          <td style="text-align:center">{:get_lastweek_name("3")}</td>
                        <td style="text-align:center">{$four['fyicount']}</td>
                        <td style="text-align:center">{$four['fyiri']}</td>
                        <td style="text-align:center">{$four['ferri']}</td>
                        <td style="text-align:center">{$four['fsanri']}</td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                          <td style="text-align:center"></td>                        
                        </tr>
                        
                          <tr>
                          <td style="text-align:center">{:get_lastweek_name("2")}</td>
                        <td style="text-align:center">{$five['wyicount']}</td>
                        <td style="text-align:center">{$five['wyiri']}</td>
                        <td style="text-align:center">{$five['werri']}</td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                          <td style="text-align:center"></td>                        
                        </tr>
                         <tr>
                          <td style="text-align:center">{:get_lastweek_name("1")}</td>
                        <td style="text-align:center">{$six['lyicount']}</td>
                        <td style="text-align:center">{$six['lyiri']}</td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>                        
                        </tr>
                          <tr>
                          <td style="text-align:center">{:get_lastweek_name("")}</td>
                        <td style="text-align:center">{$nowyi}</td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                        <td style="text-align:center"></td>
                          <td style="text-align:center"></td>                        
                        </tr>
                    </if>-->
                       <volist name="data" id="vo">
                           <tr>
                                <td>{$vo.time}</td>
                                <td>{$vo.register_num}</td>
                               <td>{:round($vo['1']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['2']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['3']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['4']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['5']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['6']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['7']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['15']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['30']/$vo['register_num'],4)*100}%</td>
                               <td>{:round($vo['60']/$vo['register_num'],4)*100}%</td>
                           </tr>
                       </volist>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page">
        {$_page|default=''}
    </div>
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('stat/userretention')}');
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
     $('#time-start').datetimepicker({
         format: 'yyyy-mm-dd',
         language:"zh-CN",
         minView:2,
         autoclose:true
    });

    $('#time-end').datetimepicker({
       format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true,
        pickerPosition:'bottom-left'
    })
    
    
    $("#game").on('click',function(event) {
        var navlist = $(this).find('.i_list_li');
        if (navlist.hasClass('hidden')) {
            navlist.removeClass('hidden');
            $(this).find('#i_list_id').focus().val('');            
        } else {
            navlist.addClass('hidden');
        }
        $(document).one("click", function(){
            navlist.addClass('hidden');
        });
        event.stopPropagation();
    });

    $('#game #i_list_id').on('keyup',function(event) {
        var val  = $.trim($(this).val()).toLowerCase();
        $(this).closest('.drop-down').find('#i_list_idh').val(val);
    });
    
    $("#game #i_list_li").find("a").each(function(){
        $(this).click(function(){
            var text = $.trim($(this).text()).toLowerCase();
            var val = $.trim($(this).attr('value'));
            $(this).closest('.drop-down').find("#i_list_id").val(text);
            $(this).closest('.drop-down').find('#i_list_idh').val(val);
        })
    });
    
    
    $("#promote").on('click',function(event) {
        var navlist = $(this).find('.i_list_li');
        if (navlist.hasClass('hidden')) {
            navlist.removeClass('hidden');
            $(this).find('#i_list_id').focus().val('');            
        } else {
            navlist.addClass('hidden');
        }
        $(document).one("click", function(){
            navlist.addClass('hidden');
        });
        event.stopPropagation();
    });

    $('#promote #i_list_id').on('keyup',function(event) {
        $(this).closest('.drop-down').find('#i_list_idh').val(-1);
    });
    
    $("#promote #i_list_li").find("a").each(function(){
        $(this).click(function(){
            var text = $.trim($(this).text()).toLowerCase();
            $(this).closest('.drop-down').find("#i_list_id").val(text);
            $(this).closest('.drop-down').find('#i_list_idh').val($(this).attr('value'));
        })
    });
})
</script>
</block>
